package com.xbj.cloud.controller;

import cn.hutool.core.date.DateUtil;
import com.xbj.cloud.commons.apis.Pay8001FeignApi;
import com.xbj.cloud.commons.entities.PayDTO;
import com.xbj.cloud.commons.resp.ResultData;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @Author 木火
 * @Date  2024/8/21
 * @Param
 * @Description
 **/
@RestController
@Tag(name = "feignOrder80订单微服务模块")
public class OrderController {
    private static final Logger LOG = LoggerFactory.getLogger(OrderController.class);

    @Resource
    private Pay8001FeignApi pay8001FeignApi;

    @PostMapping(value = "/feignOrder80/pay/add2")
    @Operation(summary = "新增",description = "新增支付流水方法,json串做参数")
    public ResultData addPayInfo(PayDTO payDTO){
        LOG.info("feignOrder80-新增");
        ResultData<String> resultData = pay8001FeignApi.addPay2(payDTO);
        return resultData;
    }

    @GetMapping(value = "/feignOrder80/pay/getById/{id}")
    @Operation(summary = "按照ID查流水",description = "查询支付流水方法")
    public ResultData getPayInfo(@PathVariable("id") Integer id){
        LOG.info("feignOrder80-查询");
        LOG.info("调用开始时间:"+ DateUtil.now());
        ResultData resultData = pay8001FeignApi.getById(id);
        LOG.info("调用结束时间:"+DateUtil.now());
        return resultData;
    }

    @GetMapping(value = "/feignOrder80/pay/getByIdTimeOut/{id}")
    @Operation(summary = "按照ID查流水",description = "查询支付流水方法-超时")
    public ResultData getByIdTimeOut(@PathVariable("id") Integer id){
        LOG.info("feignOrder80-查询");
        LOG.info("调用开始时间:"+ DateUtil.now());
        ResultData resultData = pay8001FeignApi.getByIdTimeOut(id);
        LOG.info("调用结束时间:"+DateUtil.now());
        return resultData;
    }

}
